package cn.manyufun.myf.app;

import android.app.Application;
import android.content.Context;
import android.content.res.Resources;

import com.orm.SugarContext;
import com.umeng.analytics.MobclickAgent;
import com.umeng.socialize.PlatformConfig;
import com.umeng.socialize.UMShareAPI;

import cn.manyufun.myf.BuildConfig;
import cn.manyufun.myf.common.commonutils.LogUtils;

import static cn.manyufun.myf.common.baseapp.AppConfig.WX_APP_ID;
import static cn.manyufun.myf.common.baseapp.AppConfig.WX_APP_SECRET;

/**
 * @author Kevin Xiao
 * @date Create Date: 2017-12-26
 * @Description
 */

public class AppApplication extends Application {
    private static AppApplication baseApplication;

    @Override
    public void onCreate() {
        super.onCreate();
        baseApplication = this;

        MobclickAgent.setDebugMode(true);
        MobclickAgent.openActivityDurationTrack(false);
//        UMConfigure.init(this, UMConfigure.DEVICE_TYPE_PHONE, null);
//        UMConfigure.setLogEnabled(true);
        MobclickAgent.setScenarioType(this, MobclickAgent.EScenarioType.E_UM_NORMAL);
        LogUtils.logInit(BuildConfig.LOG_DEBUG);
        SugarContext.init(this);
        initUMshare();
    }

    private void initUMshare() {
        PlatformConfig.setWeixin(WX_APP_ID, WX_APP_SECRET);
        UMShareAPI.get(this);
    }

    public static Context getAppContext() {
        return baseApplication;
    }

    public static Resources getAppResources() {
        return baseApplication.getResources();
    }

    @Override
    public void onTerminate() {
        super.onTerminate();
    }

}
